﻿using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public  class Member_DAL
    {
        public Member_DAL(Context context)
        {
            Context = context;
        }

        public Context Context { get; }
        /// <summary>
        /// 会员添加
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public int MemberAdd(Member_Model m)
        {
            var m1=Context.Member_Model.Add(m);
            return Context.SaveChanges();
        }
        /// <summary>
        /// 会员列表
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Phone"></param>
        /// <param name="SFZ"></param>
        /// <param name="KH"></param>
        /// <param name="CTime"></param>
        /// <returns></returns>
        public List<Member_Model> MemberShow(string?Name,string?Phone,string?SFZ,string?KH)
        {
           var m=Context.Member_Model.AsQueryable().ToList();
            if (!string.IsNullOrEmpty(Name))
            {
                m=m.Where(x => x.Name.Contains(Name)).ToList();
            }
            if (!string.IsNullOrEmpty(Phone))
            {
                m=m.Where(x=>x.Phone== Phone).ToList();
            }
            if (!string.IsNullOrEmpty(SFZ))
            {
                m = m.Where(x => x.SFZ == SFZ).ToList();
            }
            if (!string.IsNullOrEmpty(KH))
            {
                m = m.Where(x => x.KH == KH).ToList();
            }
         
            return m;
        }
    }
}
